package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils;
            import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ExtMonnifyReservedAccountsMapper;
import com.ruoyi.bizsys.domain.ExtMonnifyReservedAccounts;
import com.ruoyi.bizsys.service.IExtMonnifyReservedAccountsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * monnify虚拟账户Service业务层处理
 *
 * @author african-loan
 * @date 2021-10-28
 */
@Service
public class ExtMonnifyReservedAccountsServiceImpl extends ServiceImpl<ExtMonnifyReservedAccountsMapper,ExtMonnifyReservedAccounts> implements IExtMonnifyReservedAccountsService {

    /**
     * 查询monnify虚拟账户
     *
     * @param id monnify虚拟账户ID
     * @return monnify虚拟账户
     */
    @Override
    public ExtMonnifyReservedAccounts selectExtMonnifyReservedAccountsById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询monnify虚拟账户列表
     *
     * @param extMonnifyReservedAccounts monnify虚拟账户
     * @return monnify虚拟账户
     */
    @Override
    public List<ExtMonnifyReservedAccounts> selectExtMonnifyReservedAccountsList(ExtMonnifyReservedAccounts extMonnifyReservedAccounts) {
        return this.list(new QueryWrapper<>(extMonnifyReservedAccounts).last("order by id desc"));
    }

    /**
     * 新增monnify虚拟账户
     *
     * @param extMonnifyReservedAccounts monnify虚拟账户
     * @return 结果
     */
            @Override
    public int insertExtMonnifyReservedAccounts(ExtMonnifyReservedAccounts extMonnifyReservedAccounts) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            extMonnifyReservedAccounts.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(extMonnifyReservedAccounts);
    }

    /**
     * 修改monnify虚拟账户
     *
     * @param extMonnifyReservedAccounts monnify虚拟账户
     * @return 结果
     */
            @Override
    public int updateExtMonnifyReservedAccounts(ExtMonnifyReservedAccounts extMonnifyReservedAccounts) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    extMonnifyReservedAccounts.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(extMonnifyReservedAccounts);
    }

    /**
     * 批量删除monnify虚拟账户
     *
     * @param ids 需要删除的monnify虚拟账户ID
     * @return 结果
     */
            @Override
    public int deleteExtMonnifyReservedAccountsByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除monnify虚拟账户信息
     *
     * @param id monnify虚拟账户ID
     * @return 结果
     */
    @Override
    public int deleteExtMonnifyReservedAccountsById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public ExtMonnifyReservedAccounts getByUserId(String userId) {
        QueryWrapper<ExtMonnifyReservedAccounts> queryWrapper = new QueryWrapper<ExtMonnifyReservedAccounts>()
                .eq("usr_id", userId)
                .eq("state", UserConstants.BUSINESS_NORMAL);
        return this.getOne(queryWrapper);
    }

}
